package com.lwl.blue.commont.utils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lwl.blue.commont.base.JsonResult;
import com.lwl.blue.commont.base.PageParam;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * <p>
 *
 * </p>
 *
 * @version V0.0.1
 * @date 2020/3/30
 */
public interface ICommonService<T> extends IService<T> {
    /**
     * 查询对象
     *
     * @param id
     * @return JsonResult
     * @explain 查询对象  <swagger GET请求>
     * @author <a href=mailto:yangyanrui@yidianlife.com>xiaoyang</a>
     * @time 2019-07-22 11:40:06
     */
    @RequestMapping(value = "/getById/{id}", method = RequestMethod.GET)
    JsonResult<T> getByIdForRemote(@PathVariable("id") @NotNull Long id);

    /**
     * 添加
     *
     * @param entity
     * @return JsonResult
     * @explain 添加
     * @author <a href=mailto:yangyanrui@yidianlife.com>xiaoyang</a>
     * @time 2019-07-22 11:40:06
     */
    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    JsonResult<T> insertForRemote(@RequestBody @Valid T entity);


    /**
     * 根据id修改
     *
     * @param entity
     * @return JsonResult
     * @explain 修改
     * @author <a href=mailto:yangyanrui@yidianlife.com>xiaoyang</a>
     * @time 2019-07-22 11:40:06
     */
    @RequestMapping(value = "/updateById", method = RequestMethod.POST)
    JsonResult<T> updateWithIdForRemote(@RequestBody @Valid T entity);

    /**
     * 分页查询
     *
     * @param pageParam
     * @return JsonResult
     * @explain 分页条件查询用户
     * @author <a href=mailto:yangyanrui@yidianlife.com>xiaoyang</a>
     * @time 2019-07-22 11:40:06
     */
    @RequestMapping(value = "/getPages", method = RequestMethod.POST)
    JsonResult<IPage<Object>> getPagesForRemote(@RequestBody PageParam<T> pageParam);

    /**
     * 生成 Wrapper
     *
     * @param obj
     * @return
     */
    QueryWrapper<T> createQueryWrapper(Object obj);

    /**
     * 正序
     */
    String PARAM_ASC = "paramAsc";
    /**
     * 倒序
     */
    String PARAM_DESC = "paramDesc";
    /**
     * 开始
     */
    String START = "start";
    /**
     * 下划线 开始
     */
    String _START = "_start$";
    /**
     * 结束
     */
    String END = "end";
    /**
     * 下划线 结束
     */
    String _END = "_end$";
    /**
     * 主键
     */
    String ID = "id";
    /**
     * idBatch
     */
    String ID_BATCH = "idBatch";
    /**
     * 创建人id
     */
    String CREATE_ID = "createId";
    /**
     * 创建人姓名
     */
    String CREATE_NAME = "createName";
    /**
     * 创建时间
     */
    String CREATE_TIME = "createTime";
    /**
     * 修改时间
     */
    String UPDATE_TIME = "updateTime";
    /**
     * 修改人姓名
     */
    String UPDATE_NAME = "updateName";
    /**
     * 创建人id
     */
    String UPDATE_ID = "updateId";

    /**
     * 分页VO
     */
    String PAGE_VO = "PageVO";
    /**
     * 删除状态：0不删除 1删除
     */
    String DEL_FLAG = "delFlag";
    /**
     * 分页
     */
    int PAGE = 1;
    /**
     * 新增
     */
    int SAVE = 2;
    /**
     * 修改
     */
    int UPDATE = 3;


}
